package com.google.code.training_java_basic.oop;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

public class FM {

	private static final Logger logger = Logger.getLogger(FM.class);

	public static void main(String args[]) {

		logger.info("Log4j started OK");

		List<NetworkElementConnector> connectors = new ArrayList<NetworkElementConnector>();
		
		NetworkElement networkElement = new NetworkElement();
		networkElement.setIp("172.22.48.15");
		networkElement.setNetworkElementName("Node1");
		Account account = new Account();
		account.setUserName("ftp1user");
		account.setPassword("password");
		NetworkElementConnector connector = new NetworkElementConnector();
		connector.setAccount(account);
		connector.setConnectionName("Connection to Node1");
		connector.setNetworkElement(networkElement);
		connectors.add(connector);
		
		NetworkElement networkElement2 = new NetworkElement();
		networkElement2.setIp("172.22.48.15");
		networkElement2.setNetworkElementName("Node2");
		Account account2 = new Account();
		account2.setUserName("ftp2user");
		account2.setPassword("password");
		NetworkElementConnector connector2 = new NetworkElementConnector();
		connector2.setAccount(account2);
		connector2.setConnectionName("Connection to Node2");
		connector2.setNetworkElement(networkElement2);
		connectors.add(connector2);

		AlarmCollectorService alarmCollector = new AlarmCollectorServiceImpl();
		alarmCollector.setRemoteWorkingDirectory("alarms");
		alarmCollector.setRemoteFileName("^\\d+.txt$");
		alarmCollector.setLocalAlarmDirName("c:\\temp_out");
		alarmCollector.retrieveAlarmsFromAllConnectors(connectors);

		AlarmService alarmService = new AlarmServiceImpl();
		alarmService.setLocalAlarmFileName("^\\d+.txt$");
		alarmService.setLocalAlarmDirName("c:\\temp_out");

		Reports.printNetworkElementData(connectors);
		System.out.println("Node1 Info");
		List<Alarm> node1Alarms = alarmService.getAlarms("node1");
		Reports.printGeneralAlarmInfo(node1Alarms);
		Reports.printAlarms(node1Alarms);
		System.out.println("Node2 Info");
		
		List<Alarm> node2Alarms = alarmService.getAlarms("node2");
		Reports.printGeneralAlarmInfo(node2Alarms);
		Reports.printAlarms(node2Alarms);
		System.out.println("Node3 Info");
		
		List<Alarm> node3Alarms = alarmService.generateRandomAlarms(10);
		Reports.printGeneralAlarmInfo(node3Alarms);
		Reports.printAlarms(node3Alarms);
		
		connectors.remove(connector);
		connectors.remove(connector2);

		logger.info("Log4j finished OK");

	}
}
